Add new capability GTK_PRINT_CAPABILITY_NUMBER_UP.
authorCarlos Garcia Campos <carlosgc@gnome.org>
Mon, 28 May 2007 10:41:09 +0000 (10:41 +0000)
committerCarlos Garcia Campos <carlosgc@src.gnome.org>
Mon, 28 May 2007 10:41:09 +0000 (10:41 +0000)
2007-05-28  Carlos Garcia Campos  <carlosgc@gnome.org>
* gtk/gtkprinter.[ch]: Add new capability
GTK_PRINT_CAPABILITY_NUMBER_UP.
* docs/reference/gtk/tmpl/gtkprintunixdialog.sgml:
* gtk/gtkprintunixdialog.c: (update_dialog_from_capabilities):
* modules/printbackends/file/gtkprintbackendfile.c:
(file_printer_get_options), (file_printer_get_settings_from_options):
* modules/printbackends/cups/gtkprintbackendcups.c:
(cups_printer_get_capabilities): Add a new print capability to specify
whether print dialog will offer printing multiple pages per sheet. (#398414)

svn path=/trunk/; revision=17963

ChangeLog
docs/reference/gtk/tmpl/gtkprintunixdialog.sgml
gtk/gtkprinter.c
gtk/gtkprinter.h
gtk/gtkprintunixdialog.c
modules/printbackends/cups/gtkprintbackendcups.c
modules/printbackends/file/gtkprintbackendfile.c

index 5a48d7ce6c2d2124fac54f63b33a77230f4f8821..36528db2d7596ae268c3d156d48234683bc33d03 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2007-05-28  Carlos Garcia Campos  <carlosgc@gnome.org>
+
+       * gtk/gtkprinter.[ch]: Add new capability
+       GTK_PRINT_CAPABILITY_NUMBER_UP.
+       * docs/reference/gtk/tmpl/gtkprintunixdialog.sgml: 
+       * gtk/gtkprintunixdialog.c: (update_dialog_from_capabilities):
+       * modules/printbackends/file/gtkprintbackendfile.c:
+       (file_printer_get_options), (file_printer_get_settings_from_options):
+       * modules/printbackends/cups/gtkprintbackendcups.c:
+       (cups_printer_get_capabilities): Add a new print capability to specify
+       whether print dialog will offer printing multiple pages per sheet. (#398414)
+       
 2007-05-28  Matthias Clasen  <mclasen@redhat.com>
 
        * gtk/gtkwidget.c: Document some more signals
index 9b70a1b01625a46b5ec257a627e41aa1eb17cf7a..9b32c94cbff71da896acbb68a1d65b7dff250403 100644 (file)
@@ -159,7 +159,7 @@ Printing support was added in GTK+ 2.10.
 <!-- ##### ENUM GtkPrintCapabilities ##### -->
 <para>
 An enum for specifying which features the print dialog should offer.
-I neither %GTK_PRINT_CAPABILITY_GENERATE_PDF nor %GTK_PRINT_CAPABILITY_GENERATE_PS is
+If neither %GTK_PRINT_CAPABILITY_GENERATE_PDF nor %GTK_PRINT_CAPABILITY_GENERATE_PS is
 specified, GTK+ assumes that all formats are supported.
 </para>
 
@@ -171,7 +171,7 @@ specified, GTK+ assumes that all formats are supported.
 @GTK_PRINT_CAPABILITY_GENERATE_PDF: The program will send the document to the printer in PDF format
 @GTK_PRINT_CAPABILITY_GENERATE_PS: The program will send the document to the printer in Postscript format
 @GTK_PRINT_CAPABILITY_PREVIEW: 
-
+@GTK_PRINT_CAPABILITY_NUMBER_UP: Print dialog will offer printing multiple pages per sheet. Since 2.12
 <!-- ##### FUNCTION gtk_print_unix_dialog_set_manual_capabilities ##### -->
 <para>
 
index b7ddcb8a26c9a66339f6458d56a40e662760d4c3..0e4bf3629dfbd9ece732339ae8ea18f750d2f33b 100644 (file)
@@ -1086,6 +1086,7 @@ gtk_print_capabilities_get_type (void)
         { GTK_PRINT_CAPABILITY_GENERATE_PDF, "GTK_PRINT_CAPABILITY_GENERATE_PDF", "generate-pdf" },
         { GTK_PRINT_CAPABILITY_GENERATE_PS, "GTK_PRINT_CAPABILITY_GENERATE_PS", "generate-ps" },
         { GTK_PRINT_CAPABILITY_PREVIEW, "GTK_PRINT_CAPABILITY_PREVIEW", "preview" },
+       { GTK_PRINT_CAPABILITY_NUMBER_UP, "GTK_PRINT_CAPABILITY_NUMBER_UP", "number-up"},
         { 0, NULL, NULL }
       };
 
index 85e15c49a4a7564ad5412908169ab178a76f43a5..2d8bec1f82c4e86bc95ad4559a1375a779de5f52 100644 (file)
@@ -40,7 +40,8 @@ typedef enum
   GTK_PRINT_CAPABILITY_SCALE        = 1 << 4,
   GTK_PRINT_CAPABILITY_GENERATE_PDF = 1 << 5,
   GTK_PRINT_CAPABILITY_GENERATE_PS  = 1 << 6,
-  GTK_PRINT_CAPABILITY_PREVIEW      = 1 << 7
+  GTK_PRINT_CAPABILITY_PREVIEW      = 1 << 7,
+  GTK_PRINT_CAPABILITY_NUMBER_UP    = 1 << 8
 } GtkPrintCapabilities;
 
 GType gtk_print_capabilities_get_type (void) G_GNUC_CONST;
index 8606d8a8dde69703d88af2c018837a5f8b407bae..114c6cf419c55eda4fe5955159df71b01d407bf4 100644 (file)
@@ -1058,6 +1058,8 @@ update_dialog_from_capabilities (GtkPrintUnixDialog *dialog)
                            caps & GTK_PRINT_CAPABILITY_REVERSE);
   gtk_widget_set_sensitive (priv->scale_spin,
                            caps & GTK_PRINT_CAPABILITY_SCALE);
+  gtk_widget_set_sensitive (GTK_WIDGET (priv->pages_per_sheet),
+                           caps & GTK_PRINT_CAPABILITY_NUMBER_UP);
 
   if (caps & GTK_PRINT_CAPABILITY_PREVIEW)
     gtk_widget_show (priv->preview_button);
index fe8f8652e2ba621214d42123cc62dcfa7a0f7150..f4108f56ecd7e0d1c40ba325415d3d3de54c1aed 100644 (file)
@@ -2875,5 +2875,6 @@ cups_printer_get_capabilities (GtkPrinter *printer)
   return
     GTK_PRINT_CAPABILITY_COPIES |
     GTK_PRINT_CAPABILITY_COLLATE |
-    GTK_PRINT_CAPABILITY_REVERSE;
+    GTK_PRINT_CAPABILITY_REVERSE |
+    GTK_PRINT_CAPABILITY_NUMBER_UP;
 }
index c596aec0b8fff8d6d05f7b430aefdefe602f6748..6356c8d4d92a762145155979ae9a7db3b4357013 100644 (file)
@@ -480,7 +480,8 @@ file_printer_get_options (GtkPrinter           *printer,
 {
   GtkPrinterOptionSet *set;
   GtkPrinterOption *option;
-  const gchar *n_up[] = { "1" };
+  const gchar *n_up[] = {"1", "2", "4", "6", "9", "16" };
+  const gchar *pages_per_sheet = NULL;
   const gchar *format_names[N_FORMATS] = { N_("PDF"), N_("Postscript") };
   const gchar *supported_formats[N_FORMATS];
   gchar *display_format_names[N_FORMATS];
@@ -496,7 +497,12 @@ file_printer_get_options (GtkPrinter           *printer,
   option = gtk_printer_option_new ("gtk-n-up", _("Pages per _sheet:"), GTK_PRINTER_OPTION_TYPE_PICKONE);
   gtk_printer_option_choices_from_array (option, G_N_ELEMENTS (n_up),
                                         (char **) n_up, (char **) n_up /* FIXME i18n (localised digits)! */);
-  gtk_printer_option_set (option, "1");
+  if (settings)
+    pages_per_sheet = gtk_print_settings_get (settings, GTK_PRINT_SETTINGS_NUMBER_UP);
+  if (pages_per_sheet)
+    gtk_printer_option_set (option, pages_per_sheet);
+  else
+    gtk_printer_option_set (option, "1");
   gtk_printer_option_set_add (set, option);
   g_object_unref (option);
 
@@ -572,7 +578,10 @@ file_printer_get_settings_from_options (GtkPrinter          *printer,
   option = gtk_printer_option_set_lookup (options, "output-file-format");
   if (option)
     gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_OUTPUT_FILE_FORMAT, option->value);
-    
+
+  option = gtk_printer_option_set_lookup (options, "gtk-n-up");
+  if (option)
+    gtk_print_settings_set (settings, GTK_PRINT_SETTINGS_NUMBER_UP, option->value);
 }
 
 static void